package com.hpf.lease.web.admin.controller;

import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.AttrKey;
import com.hpf.lease.web.admin.vo.AttrInfoVo;
import com.hpf.lease.web.admin.service.AttrKeyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "房间属性键管理")
@RequestMapping("/admin/attr")
public class AttrInfoController {
    @Resource
    AttrKeyService attrKeyService;
    @PostMapping("/key/saveOrUpdate")
    @Operation(summary = "根据id对房间的键新增或修改")
    public Result<Object> saveOrUpdate(@RequestBody AttrKey attrKey){
        return Result.build(attrKeyService.saveOrUpdateInfo(attrKey));
    }
    @GetMapping("/list")
    @Operation(summary = "查询所有房间的键和值")
    public Result<List<AttrInfoVo>> selectAll(){
        return Result.ok(attrKeyService.selectAll());
    }
}
